DataSource for Entity Framework in WPF
C1.LiveLinq.Indexing Namespace / IndexCollection<T> Class / Add Method / Add<TKey>(Expression<Func<T,TKey>>,Boolean) Method
The type of the index key.
Key selector expression of the index, see IndexDefinition<T>.KeySelector.
true if a unique index must be created.

In This Topic
    Add<TKey>(Expression<Func<T,TKey>>,Boolean) Method
    In This Topic
    Creates a new index and adds it to the collection of indexes.
    Syntax
    'Declaration
     
    Public Overloads Shadows Function Add(Of TKey)( _
       ByVal keySelector As Expression(Of Func(Of T,TKey)), _
       ByVal keyIsUnque As Boolean _
    ) As Index(Of T,TKey)

    Parameters

    keySelector
    Key selector expression of the index, see IndexDefinition<T>.KeySelector.
    keyIsUnque
    true if a unique index must be created.

    Type Parameters

    TKey
    The type of the index key.

    Return Value

    The new index added to the collection of indexes.
    Remarks

    A unique index occupies less memory and performs better than a non-unique index (although the difference isn't dramatic). Therefore, for unique keys, it's recommended to specify the corresponding index as unique.

    But do that only if you are sure that the key is indeed unique, as it imposes a uniqueness constraint on the indexed collection. An attempt to modify the indexed collection violating the uniqueness throws an System.InvalidOperationException.

    See Also